﻿using Onshi.POS.Formularios.Recursos;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Onshi.POS.Formularios.Controles
{
    public partial class ArticulosSeleccionarDetalle : FormularioBase
    {
        #region Constructores

        public ArticulosSeleccionarDetalle(DataTable detalles)
        {
            InitializeComponent();
            this.detalles = detalles;
        }

        #endregion

        #region Atributos

        private DataTable detalles;
        private Int32 idDetalleSeleccionado;

        #endregion

        #region Propiedades

        public Int32 IdDetalleSeleccionado
        {
            get { return idDetalleSeleccionado; }
        }

        #endregion

        #region Eventos

        private void ArticulosSeleccionarDetalle_Load(Object sender, EventArgs e)
        {
            grdDetalles.AutoGenerateColumns = true;
            bsDetalles.DataSource = detalles;
        }

        private void btnAceptar_Click(Object sender, EventArgs e)
        {
            if (bsDetalles.Current != null)
            {
                idDetalleSeleccionado = (Int32)grdDetalles.SelectedRows[0].Cells[0].Value;
                DialogResult = DialogResult.OK;
            }
        }

        private void btnCancelar_Click(Object sender, EventArgs e)
        {
            Close();
        }

        #endregion
    }
}
